<template>
	<view>
		<view>
			<!-- 左侧通讯录 -->
			<scroll-view class="scroll-container" scroll-y="true" :scroll-into-view="toView" v-if="isShow"
				scroll-with-animation="true">
				<!-- <view class="common-text-view pad28-8-6">常用</view>
				<scroll-view class="scroll-view-class" :scroll-x="true">
					<view class="scroll-view-class-box margin28">
						<view v-for="(item,index) in commonLocation" :key="index">
							<view class="content-item-view" @click="commonClick()">
								<view class="name-text">{{item.name}}</view>
							</view>
						</view>
					</view>
				</scroll-view> -->
				<view class="name-text-view" @click="NOLimiClick()">不限</view>
				<view v-for="(item, index) in locationDataList" :key="index" :id="item.key">
					<view @click="click_item(item)">
						<view class="name-text-view">{{ item.name }}</view>
					</view>
				</view>
			</scroll-view>

			<!-- 右侧字母导航条 -->
			<view class="letter-nav">
				<view :class="temp==index?'right-view-text-select':'right-view-text'"
					v-for="(item, index) in locationDataList" :key="index" @click="toSelectIndex(item.key,index)"
					v-if="item.key">
					{{item.key}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getAddressMarketList
	} from '@/api/base.js'
	export default {
		data() {
			return {
				temp: 0,
				toView: '',
				commonLocation: [],
				locationDataList: [],
				registration_province: '', //省name
				registration_province_id: '', //省id

				isShow: true,
				selectInta: 0


			}
		},
		onLoad(option) {
			this.$utils.log("选择城市页面打印  " + JSON.stringify(option))
			if (option.economize_id) {
				//获取省数据
				var that = this
				this.registration_province_id = option.economize_id
				this.registration_province = option.registration_province
				getAddressMarketList(option.economize_id).then(res => {
					that.$utils.log("打印返回的 城市数据   " + JSON.stringify(res))
					that.isShow = false
					if (res.code == 0) {
						that.locationDataList = res.data
						that.$forceUpdate()
						that.isShow = true
					}
				})
			}
			if (option.selectInta) {
				this.selectInta = option.selectInta
			}
		},
		methods: {
			toSelectIndex(item, index) {
				this.toView = item
				this.temp = index
			},
			click_item(item) {
				item.registration_province_id = this.registration_province_id
				item.registration_province = this.registration_province
				this.Backhaul(item)
			},
			commonClick(item) {
				item.registration_province_id = this.registration_province_id
				item.registration_province = this.registration_province
				this.Backhaul(item)
			},
			NOLimiClick() {
				var item = {}
				item.registration_province_id = this.registration_province_id
				item.registration_province = this.registration_province
				item.name = '不限'
				this.Backhaul(item)
			},
			Backhaul(obj) {
				// 获取当前页上的栈（数组形式）
				var pages = getCurrentPages()
				//上上一页面 
				var prevPage = pages[pages.length - 3]
				obj.MID = 3
				obj.selectInta = this.selectInta
				this.$utils.log("打印返回的地址数据   "  + JSON.stringify(obj))
				prevPage.$vm.backData(obj) /// backData为A页面定义好的一个方法 调用该方法obj数据会返回到A页面backData方法中
				// 返回上上一页
				uni.navigateBack({
					delta: 2
				})
			}


		}
	}
</script>

<style>
	.content-item-view {
		width: 134rpx;
		height: 54rpx;
		background: #F4F4F499;
		border-radius: 28rpx;
		text-align: center;
		margin-right: 20rpx;
	}

	.name-text {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		line-height: 54rpx;
		color: #333333;
		opacity: 1;
	}

	.common-key-text {
		width: 100%;
		height: 58rpx;
		background: #1D212505;
		border-radius: 0rpx;
		line-height: 58rpx;
		padding-left: 28rpx;
	}

	.common-text-view {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		opacity: 1;
	}

	.scroll-view-class {
		white-space: nowrap;
		background-color: white;
		height: auto;
	}

	.scroll-view-class-box {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.content-item-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.scroll-container {
		height: 100vh;
	}

	.letter-nav {
		position: fixed;
		right: 25px;
		top: 90px;
	}

	.image-view {
		width: 60rpx;
		height: auto;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 22rpx;
	}

	.common-text {
		font-size: 32rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #1C2125;
		opacity: 1;
	}



	.name-text-view {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		padding: 18rpx 0rpx 34rpx 30rpx;
		color: #333333;
		opacity: 1;
	}


	.pad28-8-6 {
		padding: 8rpx 0px 6rpx 28rpx;
	}

	.pad28 {
		padding: 22rpx 28rpx;
	}

	.margin28 {
		margin: 28rpx;
	}

	.bac-F4 {
		background-color: #F4F4F4;
	}

	.right-view-text {
		font-size: 32rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #999999;
	}

	.right-view-text-select {
		font-size: 32rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #0E59EA;
	}
</style>